package com.imooc.rabbitmq.quickstart;

import com.imooc.rabbitmq.utils.ConnectionUtils;
import com.rabbitmq.client.Channel;
import com.rabbitmq.client.Connection;
import com.rabbitmq.client.ConnectionFactory;

import java.io.IOException;
import java.util.concurrent.TimeoutException;

public class Producer {
    public static void main(String[] args) throws IOException, TimeoutException {
        Connection connection = ConnectionUtils.getConnection();

        //3. 通过Connection 创建一个channel
        Channel channel = connection.createChannel();

        for (int i = 0; i < 5; i++) {
            String msg = "Hello RabbitMQ!";
            //1.exchange（默认direct） 2.routingkey
            channel.basicPublish("","test001",null,msg.getBytes());
        }
        channel.close();
        connection.close();
    }
}
